var testData = Array.from({length: 5000}, () => Math.round(Math.random() * 10) )

var res = []
var obj = {}

for (let i of testData) {
    if (obj[i] === undefined) {
        res.push(i)
        obj[i] = i
    }
}

console.log(res)